<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
		<meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="format-detection" content="telephone=no" />
		<meta name="apple-mobile-web-app-capable" content="yes" />
		<meta content="black" name="apple-mobile-web-app-status-bar-style">
		<link href="css/SYSFrame.css" rel="stylesheet" type="text/css" />
		<link href="font/iconfont.css" rel="stylesheet" type="text/css" />
		<link href="css/module.css" rel="stylesheet" type="text/css" />
		<link href="css/pages.css" rel="stylesheet" type="text/css" />
		<title>编辑产品</title>
		<script src="js/jquery-1.9.1.min.js" type="text/javascript"></script>
		<script src="js/jquery.nicescroll.js" type="text/javascript"></script>
		<script src="js/HUpages.js" type="text/javascript"></script>
		<script src="js/template.js" type="text/javascript"></script>
		<!--[if lt IE 9]>
          <script src="js/html5shiv.js" type="text/javascript"></script>
          <script src="js/css3-mediaqueries.js"  type="text/javascript"></script>
        <![endif]-->
	</head>

	<body id="pagestyle" class="backgroundf0">
		<div id="editcontent" class="clearfix">

		</div>
		<div class="box-module">
			<div class="box-title">编辑商品详细</div>
			<div class="box-content padding15">
				<div id="contentdetailed" class="editinfo">
				    <script id="editor" type="text/plain" style="height:500px; width: 100%;"></script>
				</div>
			</div>
		</div>
		<div class="buttonstyle">
	       <button type="button" class="btn padding10  btn-green" id="modifyproduct" onclick="modifybtn(this)">提交修改</button>
	       <button type="button" class="btn padding10 bg-deep-blue" id="addproduct" onclick="addbtn(this)">添加商品</button>
	       <button type="button" class="btn padding10 bg-gray" onclick="cancelbtn(this)">取消返回</button>
        </div>	
	</body>
</html>
<script type="text/javascript" charset="utf-8" src="js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="js/ueditor/ueditor.all.min.js">
</script>
<script type="text/javascript" charset="utf-8" src="js/ueditor/lang/zh-cn/zh-cn.js"></script>
<script>
	//内页框架
	$(function() {
		$("#pagestyle").Hupage({
			scrollbar: function(e) {
				e.niceScroll({
					cursorcolor: "#dddddd",
					cursoropacitymax: 1,
					touchbehavior: false,
					cursorwidth: "3px",
					cursorborder: "0",
					cursorborderradius: "3px",
				});
			},
			expand: function(thisBox, settings) {
				settings.scrollbar(thisBox); //设置当前页滚动样式
				//获取设置url
				$.getUrlParam = function(name) {
					var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
					var r = window.location.search.substr(1).match(reg);
					if(r != null) return unescape(r[2]);
					return null;
				}
				var productid = $.getUrlParam('productid'); //获取其中的参数值
				
				if(productid==0){
					  $("#modifyproduct").remove();
				}else{
					$("#addproduct").remove();
				}
				//数据加载
				var contents = function(callback) {
					$.ajax({
						url: "json/products.json",
						type: "GET",
						dataType: 'json',
						success: function(ret) {
							typeof callback == 'function' && callback(ret);
						},
					});
				};
				contents(function(dataArr) {
					if(productid != 0) {
						var data = dataArr.data.filter(function(e) {
							return e.id == productid;
						});
					} else {
						var data = [];
					}
					$.ajax({
						url: "html/product/content.html",
						type: "GET",
						dataType: "html",
						success: function(result) {
							$('body').append("<script id='edithtml' type='text/html'>" + result + "</script\>");
							var contenthtml = $('#editcontent');
							var htmls = template('edithtml', {
								id: productid,
								content: data,
								brand: dataArr.brandlist
							});
							contenthtml.html('');
							contenthtml.html(htmls);
							var ue = UE.getEditor('editor');
							ue.ready(function() {
								if(data != ""){
								//设置编辑器的内容
								ue.setContent(data[0].contents);
							    }
								//获取html内容
								var html = ue.getContent();
							});
							var radios = document.getElementsByName("statusradio");
							for(var i = 0; i < radios.length; i++) {
								var radioid = radios[i].dataset.id;
								radios[0].checked = true;
								if(data != "") {
									if(data[0].status == radioid) {
										radios[i].checked = true;
									} else {
										radios[i].checked = false;
									}
								}
							};
							$("#edithtml").remove(); //加载完毕删除模版路径
						}
					});

				});
			}
		})
	});
</script>
<script src="js/common.js" type="text/javascript"></script>